
<?php
//模块插件类
//对外接口函数类，其他插件可通过“$this->plugin('模块名称')->方法名” 来调用本类的方法
defined('BY_JYA') or exit('error');
class func_jy_medicalai extends plugin{
		public function yl($image){
			$setting=$this->get_setting($postdata);
			$host = "http://laboratory-sheet.imedical.xin";
			$path = "/laboratory_sheet/ocr_sheet_format";
			$method = "POST";
			$appcode = $setting['appcode'];
			$headers = array();
			array_push($headers, "Authorization:APPCODE " . $appcode);
			//根据API的要求，定义相对应的Content-Type
			array_push($headers, "Content-Type".":"."application/json; charset=UTF-8");
			$querys = "";
			$bodys=array('input_type'=>'url','content'=>$image);
			$bodys =json_encode($bodys);
			$url = $host . $path;

			$curl = curl_init();
			curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
			curl_setopt($curl, CURLOPT_URL, $url);
			curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
			curl_setopt($curl, CURLOPT_FAILONERROR, false);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
			curl_setopt($curl, CURLOPT_HEADER, true);
			if (1 == strpos("$".$host, "https://"))
			{
				curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
				curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
			}
			curl_setopt($curl, CURLOPT_POSTFIELDS, $bodys);
			$result = curl_exec($curl);
			if($result){
				$result= json_decode($result,true);
			}
			return $result['contents'];
			
		}
}
?>
